package com.ruoyi.patrol.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.patrol.domain.PtProcessOpinion;
import com.ruoyi.patrol.service.IPtProcessOpinionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 流程意见Controller
 * 
 * @author lkm
 * @date 2022-11-10
 */
@RestController
@RequestMapping("/patrol/opinion")
public class PtProcessOpinionController extends BaseController
{
    @Autowired
    private IPtProcessOpinionService ptProcessOpinionService;

    /**
     * 查询流程意见列表
     */
    @PreAuthorize("@ss.hasPermi('patrol:opinion:list')")
    @GetMapping("/list")
    public TableDataInfo list(PtProcessOpinion ptProcessOpinion)
    {
        startPage();
        List<PtProcessOpinion> list = ptProcessOpinionService.selectPtProcessOpinionList(ptProcessOpinion);
        return getDataTable(list);
    }

    /**
     * 导出流程意见列表
     */
    @PreAuthorize("@ss.hasPermi('patrol:opinion:export')")
    @Log(title = "流程意见", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PtProcessOpinion ptProcessOpinion)
    {
        List<PtProcessOpinion> list = ptProcessOpinionService.selectPtProcessOpinionList(ptProcessOpinion);
        ExcelUtil<PtProcessOpinion> util = new ExcelUtil<PtProcessOpinion>(PtProcessOpinion.class);
        return util.exportExcel(list, "opinion");
    }

    /**
     * 获取流程意见详细信息
     */
    @PreAuthorize("@ss.hasPermi('patrol:opinion:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ptProcessOpinionService.selectPtProcessOpinionById(id));
    }

    /**
     * 新增流程意见
     */
    @PreAuthorize("@ss.hasPermi('patrol:opinion:add')")
    @Log(title = "流程意见", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PtProcessOpinion ptProcessOpinion)
    {
        return toAjax(ptProcessOpinionService.insertPtProcessOpinion(ptProcessOpinion));
    }

    /**
     * 修改流程意见
     */
    @PreAuthorize("@ss.hasPermi('patrol:opinion:edit')")
    @Log(title = "流程意见", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PtProcessOpinion ptProcessOpinion)
    {
        return toAjax(ptProcessOpinionService.updatePtProcessOpinion(ptProcessOpinion));
    }

    /**
     * 删除流程意见
     */
    @PreAuthorize("@ss.hasPermi('patrol:opinion:remove')")
    @Log(title = "流程意见", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ptProcessOpinionService.deletePtProcessOpinionByIds(ids));
    }
}
